package com.smarttable.ysd.manager;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by henryhuang on 2016/5/4.
 */
public class SharedPreferenceManager {
    private static final String SHARED_PERFERENCE_NAME = "yunshidai.conf";
    private static final String LOCK_KEY = "lock";
    private static final String UNLOCK_KEY = "unlock";
    private SharedPreferences mSharedPreferences;
    private static SharedPreferenceManager mInstance;
    private SharedPreferenceManager(Context context)
    {
        mSharedPreferences = context.getSharedPreferences(
                SHARED_PERFERENCE_NAME, Context.MODE_PRIVATE);
    }
    public static SharedPreferenceManager getInstance(Context context)
    {

        if( mInstance == null )
        {
            synchronized (SharedPreferenceManager.class)
            {
                if( mInstance == null )
                {
                    mInstance = new SharedPreferenceManager(context);
                }
            }

        }
        return mInstance;
    }

    public void  saveGestureLock(String choosePattern)
    {
        mSharedPreferences.edit().putString(LOCK_KEY,choosePattern).commit();
    }

    public String getGestureLock(Context context)
    {
        String patternString = mSharedPreferences.getString(LOCK_KEY, null);
        return patternString;
    }

    public void  saveGestureUnLock(boolean success)
    {
        mSharedPreferences.edit().putBoolean(UNLOCK_KEY, success).commit();
    }

    public boolean  isGestureUnLock()
    {
        return mSharedPreferences.getBoolean(UNLOCK_KEY,false);
    }

}
